package com.tjrac.generalpermissions;

import com.tjrac.generalpermissions.dao.PTypeDao;
import com.tjrac.generalpermissions.dao.PermissionDao;
import com.tjrac.generalpermissions.dao.RoleDao;
import com.tjrac.generalpermissions.domain.PType;
import com.tjrac.generalpermissions.domain.Role;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.io.InputStream;

/**
 * @author ZeNing
 * @create 2020-11-27 21:26
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class MyTestAnnotation {

    @Autowired
    private PermissionDao permissionDao;

    @Autowired
    private RoleDao roleDao;

    @Autowired
    private PTypeDao pTypeDao = null;
//
//    @Before
//    public void before() throws Exception {
//        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
//        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
//        SqlSessionFactory build = sqlSessionFactoryBuilder.build(resourceAsStream);
//        SqlSession sqlSession = build.openSession(true);
//        permissionDao = sqlSession.getMapper(PermissionDao.class);
//    }
//
//    @Test
//    public void test() {
////        permissionDao.queryAll().stream().forEach(System.out::println);
////        int i = permissionDao.addPermission(new Permission("张三", "张三", "123", 1));
////        System.out.println(permissionDao.queryById(10));
//        int i = permissionDao.delById(10);
//
//    }

    @Test
    public void test() {
        permissionDao.queryAll().stream().forEach(System.out::println);
//        pTypeDao.addPType(new PType("第一类权限", "第一类权限"));
    }

}
